/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cloudclient.controller;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author TimotiusNC
 */
public class CloudClientRunnable implements Runnable {
	public CloudClientRunnable(CloudClientController parent, CloudClientRunnableListener listener){
		m_parent	= parent;
		m_listener	= listener;
	}

	public void run() {
		m_running = true;

		while(m_running){
			//Populate userPanel revComboBox
			m_listener.onRevUpdate(CloudClientController.getInstance().getRev());

			//Get Latest Rev
			m_latestRev = m_parent.getLatestRevision();

			//Goto Last Revision
			if(m_latestRev > m_parent.getRev()){
				m_parent.gotoLatestRevision(m_latestRev);
			}

			//Compare the previous folder state to current folder state
			CloudClientController.getInstance().compareHashMap();
			
			try { //Do delay
				Thread.sleep(5000);
			} catch (InterruptedException ex) {
				Logger.getLogger(CloudClientRunnable.class.getName()).log(Level.SEVERE, null, ex);
			}

			System.out.println();
		}
	}

	public void stop(){
		m_running = false;
	}

	private boolean						m_running;
	private CloudClientController		m_parent;
	private int							m_latestRev;
	private CloudClientRunnableListener	m_listener;
}
